
package com.ffcs.crmd.tsp.admin.facade.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.ctg.itrdc.platform.common.entity.PageInfo;
import com.ctg.itrdc.platform.common.utils.bean.BeanUtils;
import com.ffcs.crmd.platform.core.ddd.facade.impl.AbstractCrmDomFacade;
import com.ffcs.crmd.tsp.admin.api.dto.JobDetailTrackDTO;
import com.ffcs.crmd.tsp.admin.api.facade.IJobDetailDeathTrackFacade;
import com.ffcs.crmd.tsp.admin.entity.JobDetailTrack;
import com.ffcs.crmd.tsp.admin.service.IJobDetailTrackService;

@Service("transferTrackFacade")
public class JobDetailDeathTrackFacadeImpl extends AbstractCrmDomFacade implements IJobDetailDeathTrackFacade {
    
    @Autowired
    private IJobDetailTrackService jobDetailDeathTrackService;
    
    private PageInfo<JobDetailTrackDTO> copyPageInfo(PageInfo<JobDetailTrack> pageInfo) throws Exception {
        PageInfo<JobDetailTrackDTO> pageInfoDto = new PageInfo<JobDetailTrackDTO>();
        BeanUtils.applyIf(pageInfoDto, pageInfo, false);
        pageInfoDto.setList(BeanUtils.copyList(pageInfo.getList(), JobDetailTrackDTO.class));
        return pageInfoDto;
    }
    
    /**
     * 功能说明:
     * 
     * @param clusterName
     * @param id
     * @param jobName
     * @param jobDetailName
     * @param pageNumber
     * @param pageSize
     * @return
     * @throws Exception
     */
    @Override
    public PageInfo<JobDetailTrackDTO> queryPage(JobDetailTrackDTO jobDetailTrackDTO) throws Exception {
        JobDetailTrack jobDetailTrack = new JobDetailTrack();
        BeanUtils.applyIf(jobDetailTrack,  jobDetailTrackDTO, false);
        PageInfo<JobDetailTrack> pageInfo = jobDetailDeathTrackService.queryPage(jobDetailTrack,  jobDetailTrackDTO.getPageNumber(),
             jobDetailTrackDTO.getPageSize());
        return copyPageInfo(pageInfo);
    }
    
    /**
     * 功能说明:
     * 
     * @param clusterName
     * @param id
     * @param jobName
     * @param jobDetailName
     * @return
     * @throws Exception
     */
    @Override
    public List<JobDetailTrackDTO> query(JobDetailTrackDTO jobDetailRunningDTO) throws Exception {
        JobDetailTrack jobDetailRunning = new JobDetailTrack();
        BeanUtils.applyIf(jobDetailRunning, jobDetailRunningDTO, false);
        List<JobDetailTrack> sliceList = jobDetailDeathTrackService.query(jobDetailRunning);
        return BeanUtils.copyList(sliceList, JobDetailTrackDTO.class);
    }
}
